﻿using System;
using OpenLS.Core;

namespace OpenLS.Spreadsheet
{
    class SetCellSpanUndoUnit : IUndoUnit
    {
        private readonly Cell _cell;
        private readonly int _rowSpan;
        private readonly int _columnSpan;

        public SetCellSpanUndoUnit(Cell cell)
        {
            _cell = cell;
            _rowSpan = cell.RowSpan;
            _columnSpan = cell.ColumnSpan;
        }

        public void Do()
        {
            _cell.Worksheet.SetCellSpan(_cell, _rowSpan, _columnSpan, _cell.GetRangeAddress().GetCellAddresses());
        }

        public bool Merge(IUndoUnit unit)
        {
            return false;
        }
    }
}